#pragma once

#include <map>
#include "INode.h"
#include "Vector3D.h"
#include "Matrix.h"
#include "Quaternion.h"
#include "Trigger.h"
#include "IEvent.h"

class CameraNode : public INode
{
public:
	CameraNode( Subject<Maths::Vector3D>* position = 0, Subject<Maths::Vector3D>* rotation = 0 );

	HashedString Type() const;

	Maths::Matrix getProjectionMatrix();
	Maths::Matrix getViewMatrix();
	void Enable();
	void Disable();
	void setProjection();
	bool IsProjection();
	void setOrtho();
	float& Near(); 
	float& Far();
	float& Aspect();
	float& Fovy();
	float& Left();
	float& Right();
	float& Top();
	float& Bottom();
	void Unproject( float x, float y, Maths::Vector3D& start, Maths::Vector3D& end );
	Maths::Vector3D& Position();
	Maths::Vector3D& Rotation();
	ValueTrigger<Maths::Vector3D>& getPosition( );
	ValueTrigger<Maths::Vector3D>& getRotation( );
	Maths::Vector3D getRotationAngles( );
	void setPosition( Subject<Maths::Vector3D>& subject );
	void setPosition( Maths::Vector3D& subject );
	void setRotation( Subject<Maths::Vector3D>& subject );
	void setRotation( Maths::Vector3D& subject );
	void setRotationX( float angle );
	void setRotationY( float angle );
	void setRotationZ( float angle );
	void setPostRotation( Maths::Quaternion& postrotation );
	Maths::Quaternion getPostRotation();
	bool OnResize( IEvent& event );
protected:
	Pointer<TriggerBase> m_position;
	Pointer<TriggerBase> m_orientation;
	Maths::Quaternion m_postRotation;
	float m_near, m_far, m_aspect, m_fovy;
	float m_left, m_right, m_top, m_bottom;
	bool m_projection;
};